<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%--<%@taglib uri="http://www.framework.com/taglib" prefix="frame"%>--%>
<%@taglib prefix="frame" uri="http://www.framework.com/taglib" %>
<head>
    <title>公共平台 </title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- 样式文件的引入 -->
    <link href="${ctx}/commons/css/style.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/icon.css"/>
    <!-- jqueryUI JS文件的引入 -->
    <script type="text/javascript" src="${ctx}/commons/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="${ctx}/commons/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${ctx}/commons/js/easyui-extends-validate.js"></script>
    <!-- jqueryUI国际化 -->
    <script type="text/javascript" src="${ctx}/commons/js/easyui-lang-zh_CN.js"></script>
    <!-- 开发使用的公用js方法 -->
    <script type="text/javascript" src="${ctx}/commons/js/common.js"></script>
    <!-- 开发国际化的引用，主要完成后台信息在前台提示的国际化，一定要放在最后 -->
    <script type="text/javascript">var ctx = '${ctx}';
        var actionExt = "action";
        var i18n = new Object();</script>
    <script src="${ctx}/commons/js/i18n/message_zh_CN.js" type="text/javascript"></script>
</head>

<body>
<div class="easyui-layout" data-options="fit:true,border:false" >

    <div data-options="region:'center',border:false" style="padding: 4px;">
        <table id="listApplyTable" class="easyui-datagrid"
               data-options="singleSelect:false,toolbar:'#goodstb',method:'post',rownumbers:true,fit:true,fitColumns:true,border:true,
					pagination:true,multiSort:true,remoteSort:true,striped:true,
					url:'${ctx}/auction/business/regAudit/list?auctionId=${auctionId}'"}>
            <thead>
            <tr>
                <th data-options="field:'auctionName',width:100,sortable:true,title:'项目名称'" align="center"></th>
                <th data-options="field:'regName',width:100,title:'竞拍人',sortable:true" align="center"></th>
                <th data-options="field:'regTime',width:100,title:'报名时间',sortable:true" align="center"></th>
                <th data-options="field:'updateTime',width:100,title:'更新时间',sortable:true" align="center"></th>
                <th data-options="field:'statusName',width:80,title:'状态',sortable:true" align="center"></th>
                <th data-options="field:'operate',width:100,title:'操作',formatter:operateBtn
                       <%--function(value,row,index){--%>
                         <%--return '<a href=${ctx}/auction/business/regAudit/download?id=' + row.id + ' >资料下载</a>'--%>
                         <%--+'&nbsp;<a id=pass href=javascript:void(0); onclick=approve(\'' + row.id + '\')>通过</a>'--%>
                         <%--+'&nbsp;<a href=javascript:void(0); onclick=unApprove(\'' + row.id + '\') >不通过</a>';--%>
                       <%--}--%>
                        " align="center"></th>
            </tr>
            </thead>
        </table>

    </div>
</div>
<div id="bindPicDialog"></div>
<div id="noCompetReasonDialog"></div>
</body>
<script type="text/javascript">
    //初始化表格对应的js对象
    var projectsParamObj;
    $(function() {
        //初始化表格对象数据
        projectsParamObj = new initParams(
            {
                paramObjName : 'projectsParamObj',//表格对应的实体对象名称，好区分多个表格情况下的对象
                tableId:'listApplyTable',
                addDataFormId:'addProjectsDataForm',
                showDialogId:'firstLevelDialog',
                searchID:'auditSearch',
                resetSearchID:'resetAuditSearch',
                searchFormID:'searchProjectsForm',
                updateUrl:"${ctx}/business/projectmanage/input?projectId=",
                deleteUrl:'${ctx}/business/projectmanage/remove',
                addDialogWidth:700,
                addDialogHeight:520,
                ctx:'${ctx}',
                addDialogTitle:'竞价项目信息'
            });
        //初始化查询
        init(projectsParamObj);
        //setTimeout(function(){
        //$.parser.parse(".optionsAreas");
        //},1000);
    });

    function operateBtn(val,row) {
        if (row.status == 0) {
            return '<a href=${ctx}/auction/business/regAudit/download?id=' + row.id + ' >资料下载</a>'
                +'&nbsp;<a id=pass href=javascript:void(0); onclick=approve(\'' + row.id + '\')>通过</a>'
                +'&nbsp;<a href=javascript:void(0); onclick=unApprove(\'' + row.id + '\') >不通过</a>';

        } else {
            return '<a href=${ctx}/auction/business/regAudit/download?id=' + row.id + ' >资料下载</a>';

        }
    }

    function approve(id){
        //审核通过提示
        top.$('#firstLevelDialog').dialog({
            title:"提示",
            iconCls:'icon-view',
            width: 300,
            height: 150,
            closed: false,
            inline : true,
            cache: false,
            href: '${ctx}/auction/business/regAudit/successPrompt?id='+id,
            modal: true,
            extractor : function(data){
                if($.trim(data) == "unLogin"){
                    var msn = ''||i18n[''];
                    msn = msn||i18n[data];
                    if(msn != undefined){
                        top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
                        return '';
                    }
                }
                return data;
            },
            buttons : [{text:'提交',
                iconCls:'icon-ok',
                id:'commitEntityBt',
                handler:function(){
                    if(top.$('#addApproveResonForm').form('validate')){
                        top.$('#commitEntityBt').linkbutton('disable');
                        $.ajax({
                            type: "POST",
                            timeout:20000,
                            url:  top.$('#addApproveResonForm').attr("action"),
                            data: top.$('#addApproveResonForm').serialize(),
                            success: function(data,res){
                                if(data == 'success'){
                                    top.$.messager.alert("提示",'提交成功','info',function(){
                                        $('#listApplyTable').datagrid('reload');
                                        top.$('#firstLevelDialog').dialog('close');
                                    });
                                } else if(data == 'saveUnsuccess'){
                                    top.$.messager.alert("提示",'该用户已报名成功，请勿重新审核','info',function(){
                                        $('#listApplyTable').datagrid('reload');
                                        top.$('#firstLevelDialog').dialog('close');
                                    });
                                }else if(data == 'overtime'){
                                    top.$.messager.alert("提示",'竞拍已开始，审核失败','info',function(){
                                        $('#listApplyTable').datagrid('reload');
                                        top.$('#firstLevelDialog').dialog('close');
                                    });
                                }else {
                                    top.$.messager.alert("提示",'提交失败','error',function(){
                                        $('#listApplyTable').datagrid('reload');
                                        top.$('#firstLevelDialog').dialog('close');
                                    });
                                }
                            },
                            error: function(res){
                                $.messager.alert('提示',"error",'error');
                            }
                        });
                    }
                }

            }
                ,{
                    text:'取消',
                    iconCls:'icon-cancel',
                    handler:function(){
                        top.$('#firstLevelDialog').dialog('close');
                    }}]
        });

    }

    function unApprove(id){
        //审核不通过
        top.$('#firstLevelDialog').dialog({
            title:"不通过原因",
            iconCls:'icon-view',
            width: 510,
            height: 250,
            closed: false,
            inline : true,
            cache: false,
            href: '${ctx}/auction/business/regAudit/failReson?id='+id,
            modal: true,
            extractor : function(data){
                if($.trim(data) == "unLogin"){
                    var msn = ''||i18n[''];
                    msn = msn||i18n[data];
                    if(msn != undefined){
                        top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
                        return '';
                    }
                }
                return data;
            },
            buttons : [{text:'提交',
                iconCls:'icon-ok',
                id:'commitEntityBt',
                handler:function(){
                    if(top.$('#addApproveResonForm').form('validate')){
                        var reson = top.$("#refuseComment").val();
                        if(reson == null || $.trim(reson) == ''){
                            top.$.messager.alert('提示',"请输入原因！",'info');
                            return;
                        }
                        top.$('#commitEntityBt').linkbutton('disable');
                        $.ajax({
                            type: "POST",
                            timeout:20000,
                            url:  top.$('#addApproveResonForm').attr("action"),
                            data: top.$('#addApproveResonForm').serialize(),
                            success: function(data,res){
                                if(data == 'success'){
                                    top.$.messager.alert("提示",'提交成功','info',function(){
                                        $('#listApplyTable').datagrid('reload');
                                        top.$('#firstLevelDialog').dialog('close');
                                    });
                                } else if(data == 'saveUnsuccess'){
                                    top.$.messager.alert("提示",'该用户已报名成功，请勿重新审核','info',function(){
                                        $('#listApplyTable').datagrid('reload');
                                        top.$('#firstLevelDialog').dialog('close');
                                    });
                                }
                                else {
                                    top.$.messager.alert("提示",'提交失败','error',function(){
                                        $('#listApplyTable').datagrid('reload');
                                        top.$('#firstLevelDialog').dialog('close');
                                    });
                                }
                            },
                            error: function(res){
                                $.messager.alert('提示',"error",'error');
                            }
                        });
                    }
                }

            }
                ,{
                    text:'取消',
                    iconCls:'icon-cancel',
                    handler:function(){
                        top.$('#firstLevelDialog').dialog('close');
                    }}]
        });

    }

</script>